package com.grape.demo;

import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;


public class TestMe {
	
    public static void main(String[] args) {
        List<User> userList = new ArrayList<User>();
        User user7 = new User("王五", "003");
        userList.add(user7);
        User user1 = new User("张三", "001");
        userList.add(user1);
        User user2 = new User("李四", "002");
        userList.add(user2);
        User user3 = new User("李四", "003");
        userList.add(user3);
        User user4 = new User("李四", "003");
        userList.add(user4);
        User user8 = new User("李四", "003");
        userList.add(user8);
        User user5 = new User("张三", "003");
        userList.add(user5);
        User user6 = new User("王五", "003");
        userList.add(user6);
        User user9 = new User("王五", "003");
        userList.add(user9);
        
        for (User u : userList) {
            System.out.println(u.getName());
        }
        System.out.println("去重后=======>");
        
        for(int j = 0; j < userList.size(); j++) {
        	
        	String name = userList.get(j).getName();
        	System.out.println("准备删除跟"+name+"重复的");
        	
	        for(int i = j+1; i < userList.size(); i++) {
	        	if (name.equals(userList.get(i).getName())) {
	        		System.out.println("找到跟"+name+"重复的"+userList.get(i).getName());
	        		userList.remove(i);
	        		i = i-1;
				}
	        }
        }
        
        for (User u : userList) {
            System.out.println(u.getName());
        }
    }
    
}
class User {
    private String name;
    private String userId;

    public User(String name, String userId) {
        this.name = name;
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }
}
	
